home *** CD-ROM | disk | FTP | other *** search
- Path: lrz-muenchen.de!news
- From: ua302aa@lrz-muenchen.de ()
- Newsgroups: comp.lang.c
- Subject: Re: [QE] : file open problem
- Date: 7 Apr 1996 18:43:22 GMT
- Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
- Distribution: world
- Message-ID: <4k92ca$sgj@sparcserver.lrz-muenchen.de>
- References: <4k8mja$ddn@news.kreonet.re.kr>
- NNTP-Posting-Host: sun2.lrz-muenchen.de
-
- Parao@kyebek.kjist.ac.kr (Don Kim) writes:
-
- >Hello, there
-
- >I have a problem with file opening.
- >In my code,
-
- > saveTextToFile ( char *text, char *filename) {
- > FILE *file;
-
- > if ( ( file = fopen (filename, "w") = = NULL )
-
- Parenteses do not match! This cannot be the actual code, or it would
- not even compile, much less do what you describe.
-
- > cout << "Cannot open file" << endl;
-
- If you post to comp.lang.c, how about "fputs("Cannot open file\n", stderr);"?
-
- > else {
- > (void) fprintf (file, "%s\n", text);
- > (void) fclose(file);
- > }
- > }
-
- > :
- > :
-
- > char *_type = "part";
- > saveTextToFile ( _type, _type );
-
- >Is anything wrong in my source code ? My program always displays "Cannot
- >open file"....
-
- Have you considered the possibility that you cannot open the file for
- reasons specific to your file system? There could be a directory with
- the name "part", or "part" could be a write protected file.
-
- Kurt
- --
- | Kurt Watzka Phone : +49-89-2180-6254
- | watzka@stat.uni-muenchen.de
-